	<?php $this->load->view('admin/partials/bid_menu'); ?>
	<?php 
		$ci = &get_instance();
		$payStatus = array(''=>'Processing', 'completed'=>'Completed');
	?>
	<h3>Bid &raquo; <?php echo ucfirst($this->uri->segment(4,''));?></h3>

	<div class="clrboth"></div>
	
	<?php $this->load->view('admin/bid/search_partial' ); ?>
	<div class="clrboth"></div>
	
	<table border="0" class="table-list">
		<thead>
			<tr>
				<th>Bid ref</th>
				<th>Buyer Won</th>
				<th>Seller</th>
				<th>Bids on show</th>
				<th>Show name</th>
				<th>Bid date</th>
				<th>Manage</th>
			</tr>
		</thead>
		
		<tbody>
			<?php foreach( $items['items'] as $item ): ?>
				<?php 
					$BUYER = clone_( $ci->user_entity->init('id',$item->user_bid_won));
				 ?>
				<?php if($BUYER):?>
				<?php 
				 	$SHOW = $ci->show_entity->init('id',$item->id);
					$SELLER = $ci->user_entity->init('id',$item->user_created_id);
					$numberBidShow = $SHOW->countHowManyUserBidThisShow() > 0 ? "( ".$SHOW->countHowManyUserBidThisShow()." )": '';
					$BID = $ci->bid_entity->is_set($account_code= $BUYER->getAccCode(), $show_ref_no=$SHOW->getRefNo());
				?>
				<tr>
					<td><a href="javascript:void(0);" onclick="_openDialogBidInfo(<?php echo $BID->getId();?>)"><?php echo $BID->getId(); ?></a></td>
					<td><a href="javascript:void(0);" onclick="_openDialogBuyerInfo(<?php echo $BUYER->getId();?>)"><?php echo $BUYER->getFirstName()." ".$BUYER->getLastName(); ?></a></td>
					<td><a href="javascript:void(0);" onclick="_openDialogSellerInfo(<?php echo $SHOW->getUserCreatedId();?>)"><?php echo $SELLER->getFirstName()." ".$SELLER->getLastName(); ?></a></td>
					<td><a href="<?php echo site_url("admin/dataman/show/bid/?show_id=".$SHOW->getId());?>"><?php echo "View $numberBidShow"; ?></a></td>
					<td><a href="javascript:void(0);" onclick="_openDialogShowInfo(<?php echo $SHOW->getId();?>)"><?php echo $SHOW->getName(); ?></a></td>
					<td><?php echo sbxDateFormat($BID->getDateBid(),'d-M-Y'); ?></td>
					<td>
						<?php
							echo form_dropdown( 'pay_status',
												$options = $payStatus,
												$selected = array($SHOW->getPayStatus()),
												"id='show_status' onchange='change_pay_status(this.value,{$SHOW->id});' class='no-uniform'"
											);
						?>
						&nbsp;&nbsp;
						<a href="<?php echo site_url("admin/dataman/bid/email/?show_id=".$SHOW->getId()."&bid_id=".$BID->getId());?>">Email</a>
					</td>
				</tr>
			<?php endif;?>	
			<?php endforeach; ?>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="7">
					<div class="inner"><?php echo $items['pagination']['links']; ?></div>
				</td>
			</tr>
		</tfoot>
	</table>


